/*
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2014
 *
 * fileName:  SessionInvocationHandler.java
 * author:  lei
 * Company:  Cloudland Studio
 * Createdate:  2013-9-14 下午8:22:06
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2013-9-14          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.web.context.support;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;

 /**
 * <pre> 
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 java.lang.Object#toString(), 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * @ClassName  SessionInvocationHandler
 * @author  lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public class SessionInvocationHandler  implements InvocationHandler {

	/**
     * LOGGER 日志对象
     */
    private static final Logger LOGGER = Logger.getLogger(SessionInvocationHandler.class);
    
    /**
     * session Http 会话对象
     */
    private HttpSession session;
    
    public SessionInvocationHandler(HttpSession session, String jsessionId) {
        this.session = session;
    }
	
	/**
	 * @param proxy
	 * @param method
	 * @param args
	 * @return
	 * @throws Throwable
	 */
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Proxy session handle method name is: " + method.getName() + ".");
        }
		
		Object result = null;
		
		result = method.invoke(session, args);
		
		return result;
	}
	
}
